<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            border: 1px solid black;
        }
    </style>
</head>
<body>
    <div id="app">
        <h5>父组件</h5>
        <p>msg:{{msg}}</p>
        <p>{{info}}</p>
        <input type="text" v-model="info">
        <my-comp></my-comp>
    </div>
    <script type="text/x-template" id="mycomp">
        <div class="box">
            <h5>子组件</h5>
            <p>msg:{{msg}}</p>
            <p>info:{{info.value}}</p>
        </div>
    </script>
    <script type="module">
        import { createApp, computed } from "../assets/vue3/vue.esm-browser.js";
        const MyComp={
            template:'#mycomp',
            inject:["msg","info"]
        }
        createApp({
            data() {
                return {
                   msg: '注入的msg变量',
                   info:'info变量'
                }
            },
            components:{
               MyComp 
            },
            provide(){
                return {
                    msg:'注入的msg变量',
                    info:computed(()=>this.info)
                        
                    
                }
            },
        
        }).mount("#app");
    </script>
</body>
</html>